package com.ycg.vue.modules.system.mapper;

import com.ycg.vue.Annotation.AutoInsert;
import com.ycg.vue.Entity.HomeImagesEntity;
import com.ycg.vue.Entity.OperationLogEntity;
import com.ycg.vue.Entity.UserEntity;
import com.ycg.vue.Enum.AutoInsertType;
import com.ycg.vue.modules.system.Entity.TypeItemEntity;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * @Description
 * @Author jink
 * @Date 2024/2/15 18:20
 */
@Mapper
public interface SystemMapper {

    @AutoInsert(value = AutoInsertType.LOG)
    void insertLog(@Param("log") OperationLogEntity log);

    @Insert("INSERT INTO home_images (id, group_id) values (#{id},#{groupId})")
    void uploadHomePage(@Param("id") String id, @Param("groupId") String groupId);

    List<Map<String,Object>> homeImageList(@Param("home") HomeImagesEntity home);

    @Select("SELECT * FROM home_images WHERE id = #{id}")
    HomeImagesEntity selectHomePageById(String id);

    void updateHomePageById(@Param("id") String id,@Param("status")String status,@Param("collect")String collect);

    @Select("SELECT i.* FROM type_item i LEFT JOIN type_group g ON i.parent_id = g.id WHERE g.group_code = #{code}")
    List<TypeItemEntity> selectTypeByCode(@Param("code") String code);

    @Select("SELECT * FROM user WHERE id = #{id}")
    UserEntity selectById(String id);
}
